import store from '@renderer/store'

// 用于解决动态模块重复注册的错误
export const hotModuleUnregisterModule = (name: string) => {
  if (!name) return
  if ((store.state as any)[name]) {
    store.unregisterModule(name)
  }
}

// json数据存入本地存储
export const saveJsonStorage = (key: string, value) => {
  localStorage.setItem(key, JSON.stringify(value))
}

// 从本地存储读取json数据
export const loadJsonStorage = (key: string) => {
  const str = localStorage.getItem(key)
  return str ? JSON.parse(str) : null
}
